package com.example.mallsystem1104.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.mallsystem1104.entity.Avatar;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author zy
 * @Date 2024/12/12 15:24
 * @packageName:com.example.mallsystem1104.mapper
 * @ClassName:AvatarMapper
 */
@Mapper
public interface AvatarMapper extends BaseMapper<Avatar> {
    @Select("select * from avatar where md5=#{md5}")
    Avatar selectByMd5(String md5);

    @Insert("insert into avatar(md5,url,type,size) values(#{md5},#{url},#{type},#{size})")
    void save(Avatar avatar);

    @Select("select * from avatar limit #{index},#{pageSize}")
    List<Avatar> selectAvatarPage(int index, int pageSize);

    @Select("select count(*) from avatar")
    int getTotal();
}
